#include "TextureIdPool.h"

namespace core {

	TextureIdPool::TextureIdPool( GLuint count ) :
		m_count( count )
	{
		m_textures = new GLuint[count];
		glGenTextures( m_count, m_textures );
		for( int i = 0; i < m_count; ++i )
			m_freeTextures.push( m_textures[i] );
	}

	TextureIdPool::~TextureIdPool() {
		glDeleteTextures( m_count, m_textures );
	}

	GLuint TextureIdPool::Take() {
		GLuint tex = m_freeTextures.front();
		m_freeTextures.pop();
		return tex;
	}

	void TextureIdPool::Put( GLuint texId ) {
		m_freeTextures.push( texId );
	}

}
